package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.pojo.DTO.UpdateBaseDTO;
import com.example.pojo.VO.Result;
import com.example.pojo.entrity.Users;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from users where username =#{username} ")
    Users get(String username);

    @Insert("insert into user (password,email,user_id) values (#{password},#{email},#{userId})")
    void insert(Users users);

    @Select("select * from user where user_id =#{userId} ")
    Users findById(String userId);

    @Update("update user as password = #{password} where userId=#{userId}")
    void updatePwd(String password, String userId);

    @Update("update user as email = #{email} where userId=#{userId}")
    void updateEmail(String userId, String email);

    void updateBase(String userId, UpdateBaseDTO baseDTO);

    @Update("update user as avatar=#{avatar} where userId=#{id}")
    void updateAvatar(String avatar, Integer id);

    @Select("select * from user where email=#{email}")
    Users findByEmail(String email);
}
